//
//  MineTableViewCell.m
//  MeterMart
//
//  Created by ENERGY on 2018/9/20.
//  Copyright © 2018年 ENERGY. All rights reserved.
//

#import "MineTableViewCell.h"

@interface MineTableViewCell ()
@property (nonatomic, strong)UIView * whiteBGView;
@property (nonatomic, strong)UILabel * titleLab;
@property (nonatomic, strong)UIView * lineView;
@property (nonatomic, strong)UIImageView * arrowImg;
@end
@implementation MineTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.contentView.backgroundColor = getColor(mainColor);
        __weak typeof (self)weakSelf = self;
        [self.contentView addSubview:self.whiteBGView];
        [self.contentView addSubview:self.titleLab];
        [self.contentView addSubview:self.lineView];
        [self.contentView addSubview:self.arrowImg];
        [self.whiteBGView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.contentView.mas_left).mas_offset(15/WIDTH_6_SCALE);
            make.right.equalTo(weakSelf.contentView.mas_right).mas_offset(-15/WIDTH_6_SCALE);
            make.top.bottom.equalTo(weakSelf.contentView);
        }];
        [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(weakSelf.whiteBGView.mas_bottom);
            make.height.mas_offset(1/WIDTH_6_SCALE);
            make.left.equalTo(weakSelf.whiteBGView.mas_left).mas_offset(25/WIDTH_6_SCALE);
            make.right.equalTo(weakSelf.whiteBGView.mas_right);
        }];
        [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.lineView.mas_left);
            make.top.equalTo(weakSelf.whiteBGView.mas_top);
            make.bottom.equalTo(weakSelf.lineView.mas_top);
        }];
        [self.arrowImg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(weakSelf.whiteBGView.mas_right).mas_offset(-25/WIDTH_6_SCALE);
            make.centerY.equalTo(weakSelf.titleLab.mas_centerY);
            make.width.mas_offset(8/WIDTH_6_SCALE);
            make.height.mas_offset(14/WIDTH_6_SCALE);
        }];
    }return self;
}
#pragma mark - init
- (UIView *)whiteBGView{
    if (!_whiteBGView) {
        _whiteBGView = [[UIView alloc] init];
        _whiteBGView.backgroundColor = [UIColor whiteColor];
    }return _whiteBGView;
}
- (UIView *)lineView{
    if (!_lineView) {
        _lineView = [[UIView alloc] init];
        _lineView.backgroundColor = getColor(mainColor);
    }return _lineView;
}
- (UILabel *)titleLab{
    if (!_titleLab) {
        _titleLab = [[UILabel alloc] init];
        _titleLab.font = DEF_FontSize_14;
        _titleLab.textColor = [UIColor blackColor];
        _titleLab.textAlignment = NSTextAlignmentLeft;
        _titleLab.text = @"地址管理";
    }return _titleLab;
}
- (UIImageView *)arrowImg{
    if (!_arrowImg) {
        _arrowImg = [[UIImageView alloc] init];
        _arrowImg.image = [UIImage imageNamed:@"in"];
    }return _arrowImg;
}
- (void)setModel:(NSDictionary *)model{
    _model = model;
    self.titleLab.text = model[@"title"];
}
@end
